/**
 * @copyright SilverBiology, LLC
 * @website http://www.silverbiology.com
*/

Ext.namespace('Gbif.Glossary')

Gbif.Glossary.TermsTreePanel = function(config){
	
	Ext.apply(this,config,{
			autoScroll: true
		, title: 'Contents'				
		,	useArrows: true
		,	iconCls: 'iconBook'
		,	root: new Ext.tree.AsyncTreeNode()
		,	loader: new Ext.tree.TreeLoader({
					dataUrl:'api/api.php'
				,	baseParams: {
							cmd:'listTerms'
						,	type:''
						,	text:''
					}
			})			
		,	listeners: {
				click:function(node,e){
					this.fireEvent('nodeClicked',node,this);				
				}
			,	beforeload:function(node){
					if (node.attributes.type == null && node.attributes.text == null) {
						this.loader.baseParams.type = '';
						this.loader.baseParams.text = '';
					}	else {
						this.loader.baseParams.type = node.attributes.type;
						this.loader.baseParams.text = node.attributes.text;
						this.loader.baseParams.codeFlag = node.attributes.codeFlag;
					}	
				}					
			}
		,	bbar: [{
					xtype: 'button'
				,	text: 'About Software'
				,	scope: this
				,	iconCls: 'iconAbout'
				,	handler: function(){
						GBif.Stats.log( 'About');			
						this.fireEvent('aboutSoftware',this);
					}
				}
			]
		});

	Gbif.Glossary.TermsTreePanel.superclass.constructor.call(this,config)
	
}

Ext.extend( Gbif.Glossary.TermsTreePanel , Ext.tree.TreePanel, {
});